Learn R Programming

MXM (version 0.9.3)

Ancestors of a node in a directed graph: Returns and plots, if asked, the ancestors of a node (or variable)

Description

Returns and plots, if asked, the ancestors of a node (or variable).

Usage

findAncestors(G, node, graph = FALSE)

Arguments

G
The graph matrix as produced from pc.or or any other algorithm which produces directed graphs.
node
A numerical value indicating the node (or variable) whose ancestors are to be returned.
graph
A boolean variable. If TRUE the relevant graph will appear (if there are ancestors).

Value

isAnc
A matrix of the same dimensions as the original graph matrix with 0s and 1s. isAnc[i, j] = 1 indicates that the i-th node is an ancestor of the j-th node.
Ganc
A matrix of dimensions equal to the number of ancestors of the node with 0s and 1s.
anc
The ancestors of the node.

Details

The functions searches for the ancestors of some node. This is an S3 class output.

See Also

plota, nei, pc.or

Examples

Run this code
# simulate a dataset with continuous data
# simulate a dataset with continuous data
y = rdag(1000, 10, 0.3)
tru = y$G 
x = y$x
mod = pc.con(x)
G = pc.or(mod)$G
plota(G)
findAncestors(G, 1, graph = FALSE)

Run the code above in your browser using DataLab